<?php 

function downloadFileToClient($dlDir, $dlFileName, $dlType) {
    $fPath = $dlDir . $dlFileName;
    if (!file_exists ($fPath)) {    
        return false;//header('HTTP/1.1 404 NOT FOUND');  
    }  
    
    $tp = "application/octet-stream"; //binary, unkown type
    switch($dlType) {
    case "txt":
        $tp = "text/xml";
        break;
    default:
        break;
    }
   
    Header ("Content-type: " . $tp); 
    Header ("Accept-Ranges: bytes");    
    Header ("Accept-Length: " . filesize ( $fPath ) );  
    Header ("Content-Disposition: attachment; filename=" . $dlFileName );      
    readfile($filename);      
    exit ();   
} 
